﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using Entity;
using BAL;
using Common;
using System.Text;
namespace Web
{
    public partial class Report : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        [WebMethod]
        public static string CheckStudent(string StudentNumber)
        {
            if (!PageValidate.IsEmpty(StudentNumber))
            {
                StudentInfo studentInfo = studentInfo = Student.GetStudentByNumber(StudentNumber);
                if (studentInfo != null)
                {
                    return studentInfo.Name;
                }
                else
                {
                    return "null";
                }
            }
            else
            {
                return "err";
            }
        }

        [WebMethod]
        public static string SaveOrder(string studentId, string studentName, string orderId, string money,string email)
        {
            PayLogInfo paylogInfo = new PayLogInfo();
            paylogInfo.StudentNum = studentId;
            paylogInfo.StudentName = studentName;
            paylogInfo.OrderId = orderId;
            paylogInfo.Money = money;
            paylogInfo.Email = email;
            try
            {
                PayLog.Save(paylogInfo);
                return "ok";
            }
            catch
            {
                return "err";
            }

        }
        [WebMethod(EnableSession= true)]
        public static string GetQuery(string studentnum, string pass)
        {
            StudentInfo studentInfo = Student.GetStudentByNumberAndPass(studentnum, pass);
            if (studentInfo != null)
            {
                HttpContext.Current.Session["QueryStudentId"] = studentInfo.Id.ToString();
                IList<int> ids = StudentScore.GetExamRoomIdByStudentId(studentInfo.Id);
                HttpContext.Current.Session["QueryExamRoomId"] = ids;
                bool isloadpage = false;
                if (ids.Count > 1)
                    isloadpage = true;
                return "{Status:\"Sucess\",IsLoadPage:\"" + isloadpage + "\"}";
            }
            else
            {
                return "{Status:\"Error\",Msg:\"学号或密码错误\"}";
            }
        }
    }
}
